import React from 'react';
import { Select } from 'antd';
import CheckboxModal from '@/pages/ETrade/components/TjFrom/TjStation/modal';

export default ({ value, options = [], onChange = () => {} }) => {
  const openModal = async () => {
    const { index, checkedKeys } = await CheckboxModal.show({
      title: '交易单元',
      value,
      treeData: options,
    });
    index === 1 && !!checkedKeys.length && onChange(checkedKeys);
  };

  return (
    <Select
      value={`结算单元${value.length}个`}
      style={{ width: '100%', fontSize: 12 }}
      bordered={false}
      open={false}
      placeholder="全部结算单元"
      showSearch={false}
      showArrow={true}
      onClick={openModal}
    />
  );
};
